﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;

namespace ALDIOrganizer
{
    public partial class Cell
    {
        public ShiftTandem Shifts;
        
        public void ClearShifts()
        {
            Shifts.Clear();
            Notes = String.Empty;
            Update();
        }

        public void AddShift(Shift pShift)
        {
            Shifts.Add(pShift);
            Shifts.Sort();
            Update();
        }

        public bool HasAnyShifts
        {
            get
            {
                return (Shifts.Count > 0);
            }
        }

        public bool HasAnyShiftsInItsRow()
        {
            var _row = (from _r in GetParent.GetAllRows
                        where _r[0].Tag == Tag
                        select _r).SingleOrDefault();
            if (_row == null)
            {
                // this shouldn't happen
                // Debugger.Break();
                return false;
            }
            foreach (Cell _c in _row) // including myself...
            {
                if (_c.HasAnyShifts)
                {
                    return true;
                }
            }
            return false;
        }
    }
}
